<?php
	
	if(isset($_GET['do']) && !empty($_GET['do']))
	{
		if ($_GET['do'] == 'display')
		{
			$sql = new db();
			$req = 'SELECT * FROM camion WHERE GLN_Transporteur='.$_SESSION['login'];
			$sql->query($req);
			$res = $sql->fetch_array();	
		}
		if ($_GET['do'] == 'update')
		{
			if(isset($_POST) && !empty($_POST['matricule']) && !empty($_POST['classenv']) && 
			!empty($_POST['emission'])&& !empty($_POST['kilometrage']))
			{
				$sql = new db();
				$req = "UPDATE camion SET Matricule='".$_POST['matricule']."', Etat='".$_POST['classenv']."', EmissionCo2_par_KM='".$_POST['emission']."', Kilometrage='".$_POST['kilometrage']."' WHERE Matricule=".$_GET['del'];
				$sql->query($req);
				$message = '<p>La mise &#224; jour &#224; &eacute;t&eacute; effectu&eacute;e.</p>';
			}
			else
			{
				$message = '<p> Les modifications n\'ont pas &eacute;t&eacute; prises en comptes, vous avez oubli&eacute; de remplir un champ. </p>';
			}
			$sql = new db();
			$req = 'SELECT * FROM camion WHERE GLN_Transporteur='.$_SESSION['login'];
			$sql->query($req);
			$res = $sql->fetch_array();	
		}
	}
?>